#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const long long mod = 1000000007;
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		char s[1100];
		scanf("%s",s);
		int len = strlen(s);
		long long f[5]={0};
		for(int i = 0;i<len;i++)
		{
			if(s[i]=='L') f[1]++;
			else if(s[i]=='O') f[2] += f[1];
			else if(s[i]=='V') f[3] += f[2];
			else if(s[i]=='E') f[4] += f[3];
		}
		printf("%I64d\n",f[4]%mod);
	}
}
